package com.ajavaer.framework.im.tencent.response;

import com.ajavaer.framework.im.tencent.model.TencentImErrorCode;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class TencentImResponse {
    /**
     * 请求处理的结果，OK 表示处理成功，FAIL 表示失败，如果为 FAIL，ErrorInfo 带上失败原因
     */
    @JsonProperty("ActionStatus")
    private String actionStatus;
    /**
     * 失败原因
     */
    @JsonProperty("ErrorInfo")
    private String errorInfo;
    /**
     * 错误码，0为成功，其他为失败，可查询 错误码表 得到具体的原因
     */
    @JsonProperty("ErrorCode")
    private Integer errorCode;

    public boolean success() {
        TencentImErrorCode parse = TencentImErrorCode.parse(this.errorCode);
        return parse != null && parse.getCode() == 0;
    }

    public String getActionStatus() {
        return actionStatus;
    }

    public void setActionStatus(String actionStatus) {
        this.actionStatus = actionStatus;
    }

    public String getErrorInfo() {
        return errorInfo;
    }

    public void setErrorInfo(String errorInfo) {
        this.errorInfo = errorInfo;
    }

    public Integer getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(Integer errorCode) {
        this.errorCode = errorCode;
    }
}
